/*
 * Copyright (c) 2020-2099 the original author or authors. All rights reserve.
 */
package org.tianyun.cloud.autoconfigure;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.tianyun.cloud.exception.ExceptionContextAware;
import org.tianyun.cloud.exception.ExceptionDefaultResolver;
import org.tianyun.cloud.ext.i18n.I18nMessageSource;

/**
 * 自动配置类
 *
 * @auther ebert_chan
 */
public class CloudAutoConfiguration {

    @Bean
    @RefreshScope
    public I18nMessageSource i18nMessageSource() {
        return new I18nMessageSource();
    }

    @Bean
    @ConditionalOnMissingBean(ExceptionContextAware.class)
    public ExceptionContextAware exceptionContextAware(I18nMessageSource i18nMessageSource) {
        ExceptionDefaultResolver resolver = new ExceptionDefaultResolver(i18nMessageSource);
        return resolver;
    }

}
